# include <bits/stdc++.h>
using namespace std;
int xans, yans, t;
string op;
int main() {
    freopen("android.in", "r", stdin);
    freopen("android.out", "w", stdout);
    cin >> op;
    cin >> t;
    for(unsigned i = 0; i < op.size(); i++) {
        if(op[i] == 'E') xans++;
        if(op[i] == 'S') yans--;
        if(op[i] == 'W') xans--;
        if(op[i] == 'N') yans++;
    }
    int times = t / op.size();
    yans *= times;
    xans *= times;
    t %= op.size();
    for(int i = 0; i < t; i++) {
        if(op[i] == 'E') xans++;
        if(op[i] == 'S') yans--;
        if(op[i] == 'W') xans--;
        if(op[i] == 'N') yans++;
    }
    cout << xans << " " << yans << endl;
}
